GBML manual / Backgrounds

room_layer_scroll_speed

Changes how far one of the room’s tile layers moves compared with the camera, in percent, across and down, while the game runs: the same setting as the layer’s Scroll speed in the Room Editor. 100 moves with the room, 50 moves half as far so the layer looks far away, 0 keeps it fixed to the screen.

Game Boy: not available

Game Boy Color: not available

Sega Genesis: not built yet

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

room_layer_scroll_speed(layer, x_percent, y_percent)

Arguments

NameType
layerroom_layer
x_percentint
y_percentint

Returns

Nothing.

Description

Changes how far one of the room's tile layers moves compared with the camera, in percent, across (x_percent) and down (y_percent), while the game runs. It is the same setting as the layer's Scroll speed in the Room Editor's Tile layers section; this call changes it from code.

layer is ROOM_LAYER_MAIN (the room's own tiles), ROOM_LAYER_FRONT or ROOM_LAYER_BACK. A room that does not have that layer does nothing.

x_percent or y_percentWhat the layer does
100moves with the room, as a layer does by itself
50moves half as far as the camera: it looks far away
0stays where it is on the screen
a minus numbermoves the other way

Use a number from -300 to 300; a number outside that counts as the nearest end. The layer moves to where its new speed puts it right away and keeps moving that way until you leave the room, so the speed is not saved: the room starts with the speeds it was given in the editor the next time it loads. The layer moves in whole pixels, so it never shakes.

Collision belongs to the Main layer and does not move with it, so a Main layer scrolled at 50 still blocks where it was painted.

A game that never sets a scroll speed, in code or in the editor, does not carry any of this.

Example

room_layer_scroll_speed(ROOM_LAYER_BACK, 25, 100);

Makes the room's Back layer move a quarter as far sideways as the camera does, and all the way up and down.

On the GBA

layer is ROOM_LAYER_MAIN (the room’s own tiles), ROOM_LAYER_FRONT or ROOM_LAYER_BACK; a room with no such layer does nothing. The layer moves to where its new speed puts it at once, and keeps moving that way until the room is left: the room starts with the speeds it was given in the editor when it loads again. Use a number from -300 to 300 (a number outside it counts as the nearest end); a minus number moves the layer the other way. The layer moves in whole pixels, so it never shakes. Collision belongs to the Main layer and does not move with it. A game that never sets a speed, in code or in the editor, carries none of this.

See also: room_layer_visiblebackground_scroll_speedtile_indextile_set_indexcamera_setBackgrounds